/**
 * 
 */
package com.itinsys.enma.domain.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.jdbc.core.RowMapper;

import com.itinsys.enma.domain.dto.ConflictReservationDTO;

/**
 * @author pferraz
 *
 */
@SuppressWarnings("rawtypes")
public class ConflictReservationDTOMapper implements RowMapper{

	@Override
	public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
		// TODO Auto-generated method stub
		SimpleDateFormat dF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		int plannId=-2;
		try{
			plannId=rs.getInt("planning_id");
			return new ConflictReservationDTO(rs.getLong("id"),rs.getString("career"),rs.getString("careerYear"), rs.getString("description"),rs.getString("sGroup") ,dF.format(new Date(rs.getTimestamp("startTime").getTime())), dF.format(new Date(rs.getTimestamp("endTime").getTime())),plannId);
		}catch(SQLException e){
			return new ConflictReservationDTO(rs.getLong("id"),rs.getString("career"),rs.getString("careerYear"), rs.getString("description"),rs.getString("sGroup") ,dF.format(new Date(rs.getTimestamp("startTime").getTime())), dF.format(new Date(rs.getTimestamp("endTime").getTime())));
		}
	}

	/**
	 * 
	 */
	public ConflictReservationDTOMapper() {
	}

	
}
